<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns the detailed City information found in the GeoIP Database</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.geoip-org-by-name.html">geoip_org_by_name</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.geoip-region-by-name.html">geoip_region_by_name</a></div>
 <div class="up"><a href="ref.geoip.html">GeoIP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.geoip-record-by-name" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">geoip_record_by_name</h1>
  <p class="verinfo">(PECL geoip &gt;= 0.2.0)</p><p class="refpurpose"><span class="refname">geoip_record_by_name</span> &mdash; <span class="dc-title">Returns the detailed City information found in the GeoIP Database</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.geoip-record-by-name-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>geoip_record_by_name</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$hostname</code></span>
   )</div>


  <p class="para rdfs-comment">
   The <span class="function"><strong>geoip_record_by_name()</strong></span> function will return the
   record information corresponding to a hostname or an IP address.
  </p>
  <p class="para">
   This function is available for both GeoLite City Edition and commercial GeoIP
   City Edition. A warning will be issued if the proper database cannot be
   located.
  </p>
  <p class="para">
   The names of the different keys of the returning associative array are as follows:
  </p>
  <p class="para">
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      &quot;continent_code&quot; -- Two letter continent code (as of version 1.0.4 with 
      libgeoip 1.4.3 or newer)
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;country_code&quot; -- Two letter country code (see
      <span class="function"><a href="function.geoip-country-code-by-name.html" class="function">geoip_country_code_by_name()</a></span>)
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;country_code3&quot; -- Three letter country code (see
      <span class="function"><a href="function.geoip-country-code3-by-name.html" class="function">geoip_country_code3_by_name()</a></span>)
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;country_name&quot; -- The country name (see
      <span class="function"><a href="function.geoip-country-name-by-name.html" class="function">geoip_country_name_by_name()</a></span>)
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;region&quot; -- The region code (ex: CA for California)
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;city&quot; -- The city.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;postal_code&quot; -- The Postal Code, FSA or Zip Code.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;latitude&quot; -- The Latitude as signed double.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;longitude&quot; -- The Longitude as signed double.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;dma_code&quot; -- Designated Market Area code (USA and Canada only)
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;area_code&quot; -- The PSTN area code (ex: 212)
     </span>
    </li>
   </ul>
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.geoip-record-by-name-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">hostname</code></em></dt>

     <dd>

      <p class="para">
       The hostname or IP address whose record is to be looked-up.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.geoip-record-by-name-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the associative array on success, or <strong><code>FALSE</code></strong> if the address 
   cannot be found in the database.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.geoip-record-by-name-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>1.0.4</td>
       <td>
        Adding the continent_code with GeoIP Library 1.4.3 or newer only
       </td>
      </tr>

      <tr>
       <td>1.0.3</td>
       <td>
        Adding country_code3 and country_name
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.geoip-record-by-name-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3648">
    <p><strong>Example #1 A <span class="function"><strong>geoip_record_by_name()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     This will print the array containing the record of host example.com.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$record&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">geoip_record_by_name</span><span style="color: #007700">(</span><span style="color: #DD0000">'www.example.com'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$record</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$record</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [continent_code] =&gt; NA
    [country_code] =&gt; US
    [country_code3] =&gt; USA
    [country_name] =&gt; United States
    [region] =&gt; CA
    [city] =&gt; Marina Del Rey
    [postal_code] =&gt; 
    [latitude] =&gt; 33.9776992798
    [longitude] =&gt; -118.435096741
    [dma_code] =&gt; 803
    [area_code] =&gt; 310
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.geoip-org-by-name.html">geoip_org_by_name</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.geoip-region-by-name.html">geoip_region_by_name</a></div>
 <div class="up"><a href="ref.geoip.html">GeoIP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
